<script>
	export default {
		globalData: {
			windowWidth: 0,
			pageWidth: 0,
			apiUrl1: 'https://www.shejiai.cc',
			apiUrl: 'https://www.shejiai.cc'
		},
		onLaunch() {
			// 初始化登录信息
			this.initLoginUser();
			let res = uni.getSystemInfoSync();
			console.log(res)

			this.globalData.windowWidth = res.windowWidth
			this.globalData.pageWidth = res.windowWidth * 0.8
			// 初始化购物车
			this.initCart();
		},
		onPageNotFound() {
			// 页面不存在时自动重定向到首页
			uni.redirectTo({
				url: 'pages/index'
			});
		},
		methods: {
			initLoginUser() {
				let loginUser = sessionStorage.getItem('loginUser');
				if (loginUser) {
					loginUser = JSON.parse(loginUser);
					if (loginUser.token) this.$store.commit('login', loginUser);
				}
			},
			initCart() {
				this.$cart.initCart();
			}
		}
	}
</script>

<style lang="scss">
	@import './common/styles/app.scss';

	* {

		outline: none;
	}

	page {
		font-family: Source Han Sans, Source Han Sans;
	}

	.pb-safe1 {
		padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
	}

	.flex-start {
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}

	.flex-end {
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.flex-center {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.space-between {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.space-around {
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.flex-column {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.text_ellipsip {
		white-space: nowarp;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	body {
		height: auto;
		min-width: $page-width;
		overflow-x: auto;
		font-size: 14px;
	}

	a {
		text-decoration: none;
	}

	button {
		font-size: 14px;
		transition: all .4s;
		border-radius: 0;

		&:active {
			opacity: .8;
		}

		&:after {
			border: none;
		}
	}

	/* 图片显示模式 */
	.thumb {
		object-fit: contain;
	}

	/* 省略长文本 */
	.elip {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
</style>